<?php


use Illuminate\Support\Str;
use Faker\Generator as Faker;
use Illuminate\Support\Facades\Hash;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
//中文 config/app.php 添加 'faker_locale' => 'zh_CN', 即可
$factory->define(\App\Models\User::class, function (Faker $faker) {
    return [
        'user_name' => $faker->userName,
        'email' => $faker->unique()->safeEmail,
        'phone' => $faker->unique()->phoneNumber,
        'email_verified_at' => now(),
        'password' => Hash::make("123456"), // password
        'remember_token' => Str::random(10),
    ];
});


$factory->define(\App\Models\UserProfile::class, function (Faker $faker) {
    return [
        'user_id'=>function(){
             return factory(App\Models\User::class)->create()->id;
        },
        'real_name' => $faker->name,
        'nick_name' => $faker->name,
        'sex' => $faker->boolean,
    ];
});
